package org.swan.web.permission.mapper;

import org.apache.ibatis.annotations.*;
import org.swan.web.permission.bean.PermissionBean;

import java.util.List;
import java.util.Optional;


public interface PermissionMapper {
    @Insert("insert into permission ( name , description , script , namespace_id ) VALUES ( #{name} , #{description} , #{script} , #{namespaceId})")
    @Options(useGeneratedKeys = true,keyProperty = "permissionId")
    long add(PermissionBean ub);
    @Select("select * from permission where permission_id = #{id}")
    Optional<PermissionBean> getById(@Param("id") long id);
    @Update("update permission set name = #{name} ,description = #{description} ,script = #{script}  where permission_id = #{permissionId}  ")
    long updateById(PermissionBean PermissionBean);
    @Delete("delete from permission where permission_id = #{PermissionId}")
    long deleteById(@Param("PermissionId") long PermissionId);
    @Select("select * from permission limit #{rows} offset #{offset}")
    List<PermissionBean> list(@Param("offset") int offset,@Param("rows") int rows);
}
